package com.smzd.ccms.domain;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.smzd.core.domain.BaseOwnedEntity;
import com.smzd.framework.annotation.ModuleGroup;
import com.smzd.framework.system.domain.Meeting;
import com.smzd.framework.system.domain.User;

@ModuleGroup(value = "ccms/admin", moduleNames = "channels", moduleName = "channel")
public class Channel extends BaseOwnedEntity<Meeting> {
	private static final long serialVersionUID = 903787051096557174L;
	public static final String SESSION_KEY_CURRENT_CHANNEL = "_current_channel";
    public static final int TYPE_CONTAINER = 0;
    public static final int TYPE_NORMAL = 1;
    public static final int TYPE_COVER = 2;
    public static final int TYPE_ISOMER_NORMAL = 3;
    public static final int TYPE_ISOMER_COVER = 4;
    public static final int TYPE_ISOMER = 5;
	// path
	private String path;
	// type
	private Integer type;
	// parent
	private Channel parent;
	// 一个标记，随意使用
	private int tag;

	private Image image;
	
	private User user;

	// 顺序
	private double sequence;

	// 后台管理的页面地址
	private String backgroundURI;

	private List<Channel> subChannels;

	private Site site;

	// 是否是样板栏目
	private boolean templateChannel;

	// 样板栏目id
	private int tempchid;

	// 栏目视角配置
	private Map<Integer, ChannelConfig> channelCfgs;
	
	// 最后一篇文章
	private Article article;
	
	// cong-论坛公告
	private String notice;

	public Channel() {

	}

	public Channel(int id) {
		super(id);
	}

	/**
	 * 获取path
	 * 
	 * @return
	 */
	public String getPath() {
		return path;
	}

	/**
	 * 设置path
	 * 
	 * @param path
	 */
	public void setPath(String path) {
		this.path = path;
	}

	/**
	 * 获取type
	 * 
	 * @return
	 */
	public Integer getType() {
		return type;
	}

	/**
	 * 设置type
	 * 
	 * @param type
	 */
	public void setType(Integer type) {
		this.type = type;
	}

	/**
	 * 获取parent
	 * 
	 * @return
	 */
	public Channel getParent() {
		return parent;
	}

	/**
	 * 设置parent
	 * 
	 * @param parent
	 */
	public void setParent(Channel parent) {
		this.parent = parent;
	}

	@Override
	public String toString() {
		return "Channel [path=" + path + ", type=" + type + ", parent="
				+ parent + ", owner=" + owner + ", id=" + id + ", name=" + name
				+ ", description=" + description + ", disabled=" + disabled
				+ "]";
	}

	public Site getSite() {
		return site;
	}

	public void setSite(Site site) {
		this.site = site;
	}

	public boolean isTemplateChannel() {
		return templateChannel;
	}

	public boolean getTemplateChannel() {
		return templateChannel;
	}

	public void setTemplateChannel(boolean templateChannel) {
		this.templateChannel = templateChannel;
	}

	public int getTempchid() {
		return tempchid;
	}

	public void setTempchid(int tempchid) {
		this.tempchid = tempchid;
	}

	public double getSequence() {
		return sequence;
	}

	public void setSequence(double sequence) {
		this.sequence = sequence;
	}

	public List<Channel> getSubChannels() {
		return subChannels;
	}

	public void setSubChannels(List<Channel> subChannels) {
		this.subChannels = subChannels;
	}

	public String getBackgroundURI() {
		return backgroundURI;
	}

	public void setBackgroundURI(String backgroundURI) {
		this.backgroundURI = backgroundURI;
	}

	public int getTag() {
		return tag;
	}

	public void setTag(int tag) {
		this.tag = tag;
	}

	public Image getImage() {
		return image;
	}

	public void setImage(Image image) {
		this.image = image;
	}

	public void addChannelCfg(ChannelConfig ccfg) {
		if (channelCfgs == null) {
			synchronized (this) {
				if (channelCfgs == null) {
					channelCfgs = new HashMap<Integer, ChannelConfig>();
				}
			}
		}
		channelCfgs.put(ccfg.getSysDict().getId(), ccfg);
	}

	public ChannelConfig getChannelConfig(int dictId) {
		if (channelCfgs == null) {
			return null;
		}
		return channelCfgs.get(dictId);
	}

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Article getArticle() {
        return article;
    }

    public void setArticle(Article article) {
        this.article = article;
    }

	public String getNotice() {
		return notice;
	}

	public void setNotice(String notice) {
		this.notice = notice;
	}
}